# 求一个3*3矩阵主对角线元素之和。

"""
1 2 3
4 5 6
7 8 9
"""

import numpy as np

# 创建一个3x3矩阵
matrix = np.array([[1, 2, 3],
                   [4, 5, 6],
                   [7, 8, 9]])

# 计算主对角线元素之和
sum_of_diagonal = np.sum(matrix.diagonal())

print(sum_of_diagonal)